package com.alex.space.commons.tree;

import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

/**
 * @author Alex
 * Created by Alex on 2018/3/13.
 */
@NoArgsConstructor
@ToString
public class AVLTreeNode implements IEntity<Integer> {

	int data;

	AVLTreeNode left;

	AVLTreeNode right;

	AVLTreeNode parent;

	/**
	 * 平衡因子
	 */
	int bf;

	@Override
	public boolean equals(Object obj) {
		return obj != null && obj instanceof AVLTreeNode && (obj == this || ((AVLTreeNode) obj).data == this.data);
	}


	@Override
	public IEntity left() {
		return left;
	}

	@Override
	public IEntity right() {
		return right;
	}

	@Override
	public Integer data() {
		return data;
	}
}
